<script setup>
import "@material/web/focus/md-focus-ring.js";
import { RouterLink } from "vue-router";

const props = defineProps(["route", "selected", "expand", "title"]);
</script>

<template>
  <li class="drawer-item" :class="{ selected, expand }">
    <RouterLink :to="props.route || ''">
      <div class="drawer-row">
        <div class="drawer-icon">
          <slot name="icon"></slot>
        </div>
        <div class="drawer-label drawer-label-bottom label-medium">
          <p><span>{{ props.title }}</span></p>
        </div>
        <div class="drawer-label drawer-label-right label-large">
          <span>{{ props.title }}</span>
        </div>
        <md-ripple></md-ripple>
      </div>
      <md-focus-ring></md-focus-ring>
    </RouterLink>
  </li>
</template>

<style scoped>
.drawer-item .drawer-row,
.drawer-item .drawer-label {
  transition-duration: var(--md-sys-motion-duration-long4);
  transition-timing-function: var(--md-sys-motion-easing-emphasized-decelerate);
}

.drawer-item .drawer-label-bottom span,
.drawer-item .drawer-label-right span {
  transition-duration: var(--md-sys-motion-duration-short3);
  transition-timing-function: var(--md-sys-motion-easing-emphasized-decelerate);
}

.drawer-item {
  width: 100%;
  display: inline-block;
}

.drawer-item a {
  color: inherit;
  text-decoration: inherit;
  outline: none;
  position: relative;
}

.drawer-item .drawer-row {
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: row;
  border-radius: 32px;
  padding-top: 4px;
  padding-bottom: 4px;
  transition-property: background-color, margin-bottom, font-variation-settings, padding;
  font-variation-settings: "FILL" 0;
  margin-bottom: 32px;
}

.drawer-item.selected .drawer-row {
  font-variation-settings: "FILL" 1;
  background-color: var(--md-sys-color-secondary-container);
}

.drawer-item.expand .drawer-row {
  padding-top: 16px;
  padding-bottom: 16px;
  margin-bottom: 0px;
}

.drawer-item .drawer-icon {
  height: 24px;
  padding-left: 16px;
  padding-right: 16px;
}

.drawer-item .drawer-label {
  font-weight: 500;
}

.drawer-item .drawer-label-right {
  width: 0;
  white-space: nowrap;
}

.drawer-item .drawer-label-bottom {
  position: absolute;
  transform: translateY(28px);
  width: var(--navigation-drawer-normal-width);
}

.drawer-item p {
  display: flex;
  justify-content: center;
  min-height: 0;
}

.drawer-item span {
  padding: 4px 0;
}

.drawer-item .drawer-label-bottom span {
  opacity: 1;
  transition-property: opacity;
}

.drawer-item.expand .drawer-label-bottom span {
  opacity: 0;
}

.drawer-item .drawer-label-right span {
  opacity: 0;
  transition-property: opacity;
}

.drawer-item.expand .drawer-label-right span {
  opacity: 1;
}
</style>
